<?php 
  require_once("../../includes/config.php"); 
  
  $sql = 'SELECT * FROM apartments
  where owner_id = ? and (status = 2 or status = 3 or status=6)';

  $binds = array();
  $period="";
  $xperiod="";
  $binds['owner_id'] = $_SESSION['user_id'];
  $aprts = query($sql,$binds);
  $currentdate = date('m/d/Y', time());
  $dates = query('SELECT * FROM co_periods');
  foreach($dates as $date)
  {
    if(check_in_range($date['period_from'], $date['period_to'], $currentdate))
    {
      $period = $date["period_id"];
      break;
    }
  }
  
	  $dates=query('SELECT * FROM periods');
	   foreach($dates as $date)
	  {
		if(check_in_range($date['period_from'], $date['period_to'], $currentdate))
		{
		  $xperiod = $date["period_id"];
		  break;
		}
	  }

if ($period==""&&$xperiod=="")
{
$period="";
$xperiod="";
}
   

renderWithoutHeader("Apartments/choose_apartment_via_company.php", array("aprts"=>$aprts,"period"=>$period,"xperiod"=>$xperiod,"coid"=>$_GET['id']));
?>